package org.raymond.iworks.apis;

import jakarta.validation.Valid;
import org.raymond.iworks.apis.common.Result;
import org.raymond.iworks.apis.fallbackFactory.ITSysUserServiceFallbackFactory;
import org.raymond.iworks.apis.vo.PageVO;
import org.raymond.iworks.apis.vo.TransFileVO;
import org.raymond.iworks.apis.vo.user.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;

@FeignClient(name="services", contextId="user",
        fallbackFactory= ITSysUserServiceFallbackFactory.class
)
public interface ITSysUserServiceApi {
    @GetMapping("/usernameAuthentication")
    Result<String> usernameAuthentication(@RequestParam(value="username") String username,
                                          @RequestParam(value="password") String password);

    //@Resource(name="user:edit")
    @PostMapping("/create")
    Result<Boolean> create(@RequestBody UserCreateVO vo);

    //@Resource(name="user:edit")
    @PostMapping("/update")
    Result<Boolean> update(@RequestBody UserUpdateVO vo);

    //@Resource(name="user:edit")
    @PostMapping("/delete")
    Result<Boolean> delete(@RequestBody UserDelVO vo);

    //@Resource(name="user:query")
    @GetMapping("/page")
    Result<PageVO<UserVO>> page(UserPageVO vo);

    //@Resource(name="user:query")
    @GetMapping("/getById")
    Result<UserVO> getById(@RequestParam(value="id") Long id);

    //@Resource(name="user:query")
    @GetMapping("/current")
    Result<UserInfoVO> current();

    @PostMapping("/login")
    Result<UserLoginVO> login(@RequestBody @Valid UserLoginVO vo);

    @PostMapping("/logout")
    Result<Boolean> logout();

    //@Resource(name="user:edit")
    @PostMapping("/importExcel")
    Result<Boolean> importExcel(@RequestBody @Valid TransFileVO transFileVO);

    //@Resource(name="user:query")
    @PostMapping("/exportExcel")
    void exportExcel(@RequestBody UserPageVO vo) throws IOException;
}
